package com.yrihr.wisdom.common;

import lombok.Data;

/**
 * @ClassName : ResponseBody
 * @Description : 请求返回结果
 * @Author : wind
 * @Date: 2020-11-24 18:36
 * @Version 1.0
 */
@Data
public class ResponseBody {
    //返回状态码
    private Integer status;

    //对返回状态码的描述
    private String description;

    //返回的数据
    private Object data;

    public ResponseBody() {
    }

    /**
     *
     * @param status
     * @param description
     * @param object
     * @return
     */
    public static ResponseBody success(Integer status, String description, Object object) {
        ResponseBody responseBody = new ResponseBody();
        responseBody.setStatus(status);
        responseBody.setDescription(description);
        responseBody.setData(object);

        return responseBody;
    }

    /**
     *
     * @param code
     * @param object
     * @return
     */
    public static ResponseBody success(ResponseCode code, Object object) {
        ResponseBody responseBody = new ResponseBody();
        responseBody.setStatus(code.status());
        responseBody.setDescription(code.description());
        responseBody.setData(object);

        return responseBody;
    }

    public static ResponseBody error(ResponseCode code, String description,Object object) {
        ResponseBody responseBody = new ResponseBody();
        return responseBody;
    }
    public static ResponseBody error(ResponseCode code, Object object) {
        ResponseBody responseBody = new ResponseBody();
        return responseBody;
    }

    @Override
    public String toString() {
        return "ResponseBody{" +
                "status=" + status +
                ", description='" + description + '\'' +
                ", data=" + data +
                '}';
    }
}

